from aliyunsdkcore import client
from aliyunsdkiot.request.v20170420 import RegistDeviceRequest
from aliyunsdkiot.request.v20170420 import PubRequest

accessKeyId = 'LTAIC69s9vEk8sDu'
accessKeySecret = 'K9K6iPbIecvPGBHcXkELCgK6lxvwrG'
clt = client.AcsClient(accessKeyId, accessKeySecret, 'cn-shanghai')

request = PubRequest.PubRequest()
request.set_accept_format('json')  #设置返回数据格式，默认为XML
request.set_ProductKey('CxglF26uDHj')
request.set_TopicFullName('/CxglF26uDHj/jmd1/data')  #消息发送到的Topic全名
request.set_MessageContent('aGVsbG8gd29ybGQ=')  #hello world Base64 String
request.set_Qos(0)
result = clt.do_action_with_exception(request)
print('result : ' + str(result))
